const request = require('./request')

const BASE_URL = '/finance/category'

/**
 * 初始化
 * @returns 
 */
function categoryInit() {
  return request.get(BASE_URL + '/init')
}

/**
 * 获取分类列表
 * @returns 
 */
function getCategoryList() {
  return request.get(BASE_URL + '/categories')
}

function categoryAdd(params) {
  return request.post(BASE_URL + '/create', params)
}
function categoryEdit(params) {
  return request.put(BASE_URL + '/edit/' + params.id, params)
}
function categoryDelete(id) {
  return request.post(BASE_URL + '/delete/' + id)
}

/**
 * 设置为默认
 * @param {*} accountId 账户id 
 * @returns 
 */
function setDefaultFlag(accountId) {
  return request.post(BASE_URL + '/set/default-flag/'+ accountId)
}


module.exports = {
  getCategoryList,
  categoryInit,
  categoryAdd,
  categoryEdit,
  setDefaultFlag,
  categoryDelete
} 